home *** CD-ROM | disk | FTP | other *** search
- Path: news.cs.ucla.edu!twinsun!not-for-mail
- From: eggert@twinsun.com (Paul Eggert)
- Newsgroups: comp.std.c
- Subject: Re: Undefined result vs. int's holding undefined values.
- Date: 6 Jan 1996 10:45:48 -0800
- Organization: Twin Sun Inc, El Segundo, CA, USA
- Message-ID: <4cmg0s$1mb@der.twinsun.com>
- References: <4ck70b$rd7@news.informix.com> <4ckms5$rd7@news.informix.com>
- NNTP-Posting-Host: der.twinsun.com
-
- This reminds me of a similar bug I found a long time ago when porting
- the Modula-3 runtime, which contained code that acted something like this:
-
- int sum_overflow (int x, int y) {
- return (x + y < x) != (y < 0);
- }
-
- The C Standard does not guarantee that the above function works,
- since integer overflow leads to undefined behavior,
- but when I found that the function did not work with whatever old version
- of GCC I was using at the time, I reported it as a bug to the GCC maintainers
- and got a fix from them in a few days.
-
- Regardless of what the C Standard says, it should be obvious that it's
- crucial to have integer overflow checking working properly in an
- application that needs it. If you can't convince SCO that their
- implementation's behavior is wrong, then my advice is to switch to a
- better supplier. I've heard that GCC works with SCO....
-